package day_2022_12_to_3.year2023;

/**
 * @author haomin
 * @date 2023/01/30 17:48
 **/
public class Day1_30_Num1669 {
    class Solution {
        public ListNode mergeInBetween(ListNode list1, int a, int b, ListNode list2) {
            ListNode l1pre = list1;
            ListNode l1next = list1;
            ListNode l2head = list2;
            ListNode l2tail = list2;
            while(a-- > 1) l1pre = l1pre.next;
            while(b-- > 0) l1next = l1next.next;
            ListNode l1r = l1next.next;
            l1next.next = null;
            while(l2tail.next != null) l2tail = l2tail.next;

            l1pre.next = l2head;
            l2tail.next = l1r;
            return list1;
        }
    }
}